package cn.edu.scau.cmi.luowanghaoyun.client;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class DBTest {
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");
		String url = "jdbc:mysql://localhost:3306/jsp";
		String username = "root"; 
		String password = "root"; 
		Connection conn = DriverManager.getConnection(url, username, password);
		
		String selectSql = "select *from tb_student";
		PreparedStatement ps = conn.prepareStatement(selectSql);
		 ResultSet rs = ps.executeQuery(selectSql); 
		 while(rs.next()) {
			 System.out.println("id:"+rs.getString(1)+", name:"+rs.getString(2));
		 }
	}

}
